package org.dding.msc.service;

import java.util.List;

import javax.management.ServiceNotFoundException;

/**
 * A service registry.  Registries can return services by name, or get a collection of service names.
 *
 */
public interface ServiceRegistry {

    /**
     * Get a service, throwing an exception if it is not found.
     *
     * @param serviceName the service name
     * @return the service controller for the corresponding service
     * @throws ServiceNotFoundException if the service is not present in the registry
     */
    ServiceController<?> getRequiredService(ServiceName serviceName) throws ServiceNotFoundException;

    /**
     * Get a service, returning {@code null} if it is not found.
     *
     * @param serviceName the service name
     * @return the service controller for the corresponding service, or {@code null} if it is not found
     */
    ServiceController<?> getService(ServiceName serviceName);

    /**
     * Get a list of service names installed in this registry.
     *
     * @return the list
     */
    List<ServiceName> getServiceNames();
}
